--- title: CTX keywords: fastai sidebar: home_sidebar summary: "Utils for working with MRO CTX data" description: "Utils for working with MRO CTX data" nb_path: "notebooks/03_ctx.ipynb" ---
{% raw %}
/Users/klay6683/Dropbox/src/nbplanetary/planetarypy/ctx.py:30: UserWarning: kalasiris has a problem initialing ISIS
  warnings.warn("kalasiris has a problem initialing ISIS")
Stored index is up-to-date.
Done.
{% endraw %} {% raw %}
/var/folders/tt/k11390b92vl_dygt4m0s7gjr008bbb/T/ipykernel_56809/2462109520.py:26: UserWarning: kalasiris has a problem initialing ISIS
  warnings.warn("kalasiris has a problem initialing ISIS")
Stored index is up-to-date.
{% endraw %} {% raw %}
edrindex.head()
VOLUME_ID FILE_SPECIFICATION_NAME ORIGINAL_PRODUCT_ID PRODUCT_ID IMAGE_TIME INSTRUMENT_ID INSTRUMENT_MODE_ID LINE_SAMPLES LINES SPATIAL_SUMMING ... SUB_SOLAR_LATITUDE SUB_SPACECRAFT_LONGITUDE SUB_SPACECRAFT_LATITUDE SOLAR_DISTANCE SOLAR_LONGITUDE LOCAL_TIME IMAGE_SKEW_ANGLE RATIONALE_DESC DATA_QUALITY_DESC ORBIT_NUMBER
0 MROX_0001 DATA/CRU_000001_9999_XN_99N999W.IMG 4A_04_0001000400 CRU_000001_9999_XN_99N999W 2005-08-30 15:40:21.549 CTX NIFL 5056 1024 1 ... 0.0 0.0 0.0 0.0 278.89 10.16 0.0 Instrument checkout image of space OK -4242
1 MROX_0001 DATA/CRU_000002_9999_XN_99N999W.IMG 4A_04_0001000500 CRU_000002_9999_XN_99N999W 2005-09-08 15:59:45.313 CTX NIFL 5056 15360 1 ... 0.0 0.0 0.0 0.0 284.48 4.60 0.0 Calibration image of the Moon OK -4126
2 MROX_0001 DATA/CRU_000003_9999_XN_99N999W.IMG 4A_04_0001000600 CRU_000003_9999_XN_99N999W 2005-09-08 16:03:37.927 CTX NIFL 5056 2048 1 ... 0.0 0.0 0.0 0.0 284.48 4.66 0.0 Calibration image of Omega Centauri (globular ... OK -4126
3 MROX_0001 DATA/CRU_000004_9999_XN_99N999W.IMG 4A_04_0001000700 CRU_000004_9999_XN_99N999W 2005-09-08 16:08:23.841 CTX NIFL 5056 2048 1 ... 0.0 0.0 0.0 0.0 284.48 4.74 0.0 Calibration image of Omega Centauri (globular ... OK -4126
4 MROX_0001 DATA/CRU_000005_9999_XN_99N999W.IMG 4A_04_0001000800 CRU_000005_9999_XN_99N999W 2005-09-08 16:11:18.649 CTX NIFL 5056 21504 1 ... 0.0 0.0 0.0 0.0 284.48 4.79 0.0 Calibration image of the Moon OK -4126

5 rows × 51 columns

{% endraw %} {% raw %}

catch_isis_error[source]

catch_isis_error(func)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

class CTXEDR[source]

CTXEDR(id_)

{% endraw %} {% raw %}
{% endraw %} {% raw %}
id_ = "F10_039666_1383_XN_41S315W"
{% endraw %} {% raw %}
ctx = CTXEDR(id_)
{% endraw %} {% raw %}
ctx
PRODUCT_ID: F10_039666_1383_XN_41S315W
URL: https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_2337/data/F10_039666_1383_XN_41S315W.IMG
Local: /home/maye/big_drive/planetary_data/missions/mro/ctx/edr/F10_039666_1383_XN_41S315W/F10_039666_1383_XN_41S315W.IMG
Shape: (1, 15360, 5056)
{% endraw %} {% raw %}
ctx.id
'F10_039666_1383_XN_41S315W'
{% endraw %} {% raw %}
assert ctx.id == ctx.product_id
{% endraw %} {% raw %}
ctx.meta
volume_id                                                 MROX_2337
file_specification_name         DATA/F10_039666_1383_XN_41S315W.IMG
original_product_id                                4A_04_10C800EF00
product_id                               F10_039666_1383_XN_41S315W
image_time                               2015-01-12 06:36:38.896000
instrument_id                                                   CTX
instrument_mode_id                                             NIFL
line_samples                                                   5056
lines                                                         15360
spatial_summing                                                   1
scaled_pixel_width                                             5.04
pixel_aspect_ratio                                              1.2
emission_angle                                                 1.29
incidence_angle                                                41.1
phase_angle                                                   42.31
center_longitude                                             315.39
center_latitude                                              -41.79
upper_left_longitude                                         315.56
upper_left_latitude                                           -42.6
upper_right_longitude                                        314.98
upper_right_latitude                                         -42.55
lower_left_longitude                                         315.79
lower_left_latitude                                          -41.04
lower_right_longitude                                        315.23
lower_right_latitude                                         -40.99
mission_phase_name                                              ESP
target_name                                                    MARS
spacecraft_clock_start_count                         1105511837:252
focal_plane_temperature                                       298.4
line_exposure_duration                                        1.877
offset_mode_id                                          197/201/189
sample_first_pixel                                                0
scaled_image_width                                            25.22
scaled_image_height                                           93.06
spacecraft_altitude                                           252.3
target_center_distance                                      3639.68
slant_distance                                               252.36
usage_note                                                        N
north_azimuth                                                 276.7
sub_solar_azimuth                                            195.36
sub_solar_longitude                                            1.25
sub_solar_latitude                                           -25.45
sub_spacecraft_longitude                                     315.27
sub_spacecraft_latitude                                      -41.77
solar_distance                                          207649812.3
solar_longitude                                              270.61
local_time                                                    15.05
image_skew_angle                                               90.2
rationale_desc                               Ride-along with HiRISE
data_quality_desc                                                OK
orbit_number                                                  39666
Name: 71275, dtype: object
{% endraw %} {% raw %}
ctx.storage
Path('/home/maye/big_drive/planetary_data/missions/mro/ctx/edr')
{% endraw %} {% raw %}
ctx.local_folder
Path('/home/maye/big_drive/planetary_data/missions/mro/ctx/edr/F10_039666_1383_XN_41S315W')
{% endraw %} {% raw %}
ctx.url
URL('https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_2337/data/F10_039666_1383_XN_41S315W.IMG')
{% endraw %} {% raw %}
ctx.download()
File exists. Use `overwrite=True` to download fresh.
{% endraw %} {% raw %}

CTXEDR.calib_pipeline[source]

CTXEDR.calib_pipeline(overwrite=False)

{% endraw %} {% raw %}
ctx.isis_import()
{% endraw %} {% raw %}
ctx.spice_init()
{% endraw %} {% raw %}
ctx.calibrate()
{% endraw %} {% raw %}
ctx.destripe()
{% endraw %} {% raw %}
ctx.calib_pipeline()
{% endraw %} {% raw %}
ctx.plot_calibrated()
{% endraw %} {% raw %}
ds = ctx.read_edr()
ds
<xarray.DataArray (band: 1, y: 15360, x: 5056)>
[77660160 values with dtype=uint8]
Coordinates:
  * band     (band) int64 1
  * y        (y) float64 0.5 1.5 2.5 3.5 ... 1.536e+04 1.536e+04 1.536e+04
  * x        (x) float64 0.5 1.5 2.5 3.5 ... 5.054e+03 5.054e+03 5.056e+03
Attributes:
    transform:   (1.0, 0.0, 0.0, 0.0, 1.0, 0.0)
    res:         (1.0, -1.0)
    is_tiled:    0
    nodatavals:  (0.0,)
    scales:      (1.0,)
    offsets:     (0.0,)
{% endraw %} {% raw %}

class CTXEDRCollection[source]

CTXEDRCollection(product_ids)

Class to deal with a set of CTX products.
{% endraw %} {% raw %}
{% endraw %} {% raw %}
ids = edrindex.sample(3).PRODUCT_ID
ids
37276     G08_021512_1757_XI_04S069W
117457    N08_065585_2033_XN_23N166W
111287    K22_061833_1777_XI_02S328W
Name: PRODUCT_ID, dtype: object
{% endraw %} {% raw %}
coll = CTXEDRCollection(ids)
{% endraw %} {% raw %}
coll.get_urls()
[URL('https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_1301/data/G08_021512_1757_XI_04S069W.IMG'),
 URL('https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_3737/data/N08_065585_2033_XN_23N166W.IMG'),
 URL('https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx/mrox_3555/data/K22_061833_1777_XI_02S328W.IMG')]
{% endraw %} {% raw %}
lazys = coll.download_collection()
lazys
Launching parallel download...
Done.
{% endraw %}